A transaction log of a database is a file that is used to record each modification action of the database. The transaction log is a basis for undoing a transaction, and restoring the transaction when a fault occurs. A difference from a common system log lies in that, when a transaction log of a database records a change of a database system, sequence consistency needs to be ensured, and when a fault is rectified, a restoration also needs to be performed completely according to a sequence in which a transaction occurs. Generally, to reduce input and output, a database system records a transaction log using a write-ahead logging (WAL) mechanism. The WAL indicates that modifications must be made to a data file after the transaction log has recorded these modifications, that is, after a log record that describes these modifications is written into a magnetic disk.
When a fault occurs in a database system, a process in which the system is restored to a previous consistent state using a transaction log is called a database restoration. Using a redo log, a modification that has been made to the system may be made again to avoid a data loss. Using an undo log, a modification that is not successfully submitted when a fault occurs may be undone, thereby ensuring consistency of a database.
Currently, a transaction log of a database is recorded in a serial mode, and the transaction log is saved using a single log buffer and a single log file. However, the serial mode causes that the transaction log is written into a magnetic disk very slowly, and a case in which a resource is locked when one request is responded to and another request must wait for unlocking of the resource may occur in the single log buffer. Therefore, lock granularity is enlarged, which causes lower availability of the database system and poor user experience.